package com.kk.util.test.thread.priority;

import com.kk.util.test.thread.Thread1;

/**
 * @function: 测试优先级
 * @结论： 优先级高的不一定比优先级慢的先执行
 * @author: kevin
 * @date: 2018-09-07 11:20
 */
public class ThreadPriority extends Thread {
    private String name;

    public ThreadPriority(String name) {
        super(name);
    }

    public synchronized void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println("线程"+name+": "+i);
        }
    }

    public static void main(String[] args){
        Thread t1 = new Thread1("A");
        Thread t2 = new Thread1("B");
        t1.setPriority(Thread.MIN_PRIORITY);
        t2.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        t2.start();

    }
}
